<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>登录</title>
    <link rel="stylesheet" href="${request.contextPath}/static/libs/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${request.contextPath}/static/modules/manager/css/login.css" />
    <link rel="icon" href="${request.contextPath}<@configValue id='CAAB580980C74A169D8AFEB418ABB5AA'> </@configValue>"
        type="image/x-icon" />
    <!--[if IE 8]>
		<style>
			.beg-login-box{-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#66ffffff,endColorstr=#66ffffff)";}
		</style>
	<![endif]-->
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
	<script src="${request.contextPath}/static/libs/html5.min.js"></script>
	<script src="${request.contextPath}/static/libs/respond.min.js"></script>
	<![endif]-->
</head>

<body>
    <div class="beg-login-bg">
        <div class="beg-login-box">
            <header>
                <h1>后台登录</h1>
            </header>
            <div class="beg-login-main">
                <form class="layui-form">
                    <input name="__RequestVerificationToken" type="hidden"
                        value="fkfh8D89BFqTdrE2iiSdG_L781RSRtdWOH411poVUWhxzA5MzI8es07g6KPYQh9Log-xf84pIR2RIAEkOokZL3Ee3UKmX0Jc8bW8jOdhqo81" />
                    <input type="hidden" name="orgid" value="${orgid}">
                    <div class="layui-form-item">
                        <label class="beg-login-icon">
                            <i class="layui-icon">&#xe612;</i>
                        </label>
                        <input type="text" name="ZHANGHM" lay-verify="ZHANGHM" autocomplete="off" maxlength="32"
                            placeholder="这里输入登录名" class="layui-input">
                    </div>
                    <div class="layui-form-item">
                        <label class="beg-login-icon">
                            <i class="layui-icon">&#xe642;</i>
                        </label>
                        <input type="password" name="abcd" lay-verify="pass" autocomplete="off" maxlength="32"
                            placeholder="这里输入密码" class="layui-input">
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <input name="vcode" lay-verify="vcode" placeholder="输入验证码" maxlength="8" autocomplete="off"
                                class="layui-input" style="width: 165px;">
                        </div>
                        <div class="layui-inline" style="margin-right:0">
                            <img id="captchaImg" src="${request.contextPath}/captcha.jpg?type=simple"
                                style="width: 90px; height: 40px" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <#---<div class="beg-pull-left beg-login-remember">
                            <label>记住帐号？</label>
                            <input type="checkbox" name="rememberMe" value="true" lay-skin="switch" checked
                                title="记住帐号">
                    </div>
                    <div class="beg-pull-right">-->
                        <button class="layui-btn layui-btn-fluid layui-btn-primary" lay-submit lay-filter="login">
                            <i class="layui-icon">&#xe650;</i> 登录
                        </button>
                        <#--< /div>--> <div class="beg-clear">
                            </div>
                    </div>
                </form>
            </div>
        </div>
        <footer class="footer-box">
            <p>快搭科技(上海)有限公司 © www.kdayun.com</p>
        </footer>
        <script type="text/javascript" src="${request.contextPath}/static/libs/layui/layui.js"></script>
        <script type="text/javascript" src="${request.contextPath}/static/libs/md5.js" type="text/javascript"></script>
        <script>
            function getOrgCode() {
                var url = window.location.href;
                url = url.replace('//', '');
                url = url.split(';')[0];
                url = url.split('?')[0];
                url = url.split('#')[0];
                var items = url.split("/");
                url = items[items.length - 1];
                var re = /^[0-9]+.?[0-9]*/;
                if (re.test(url)) {
                    return url;
                } else {
                    return '';
                }
            }
            if (window != top) {
                top.location.href = location.href;
            }
            layui.config({
                base: '${request.contextPath}/static/framework/' //静态资源所在路径
                , contentPath: '${request.contextPath}'
            }).use(['layer', 'form', 'zlContext'], function () {
                var layer = layui.layer,
                    $ = layui.jquery,
                    form = layui.form,
                    zlContext = layui.zlContext;
                form.verify({
                    u: function (value, item) { //value：表单的值、item：表单的DOM对象
                        if (value == "") {
                            return '用户名不能为空';
                        }
                        if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
                            return '用户名不能有特殊字符';
                        }
                        if (/(^\_)|(\__)|(\_+$)/.test(value)) {
                            return '用户名首尾不能出现下划线\'_\'';
                        }
                    }
                    , pass: function (value, item) {
                        if (value == "") {
                            return '密码不能为空';
                        }
                    }
                    , vcode: function (value, item) {
                        if (value == "") {
                            return '验证码不能为空';
                        }
                    }
                });
                function reloadVcode() {
                    var url = "${request.contextPath}/captcha.jpg?type=simple&${tokenidname}=" + Math.floor(Math.random() * 100);
                    $("#captchaImg").prop("src", url);
                }
                $("#captchaImg").click(function () {
                    reloadVcode();
                });
                //$('input[name="ZHANGHM"]').val('admin');
                //$('input[name="abcd"]').val('zl123456zl');

                $(document).on("keydown", function (e) {
                    e = e ? e : event;// 兼容FF
                    if (e.keyCode == 13) {
                        $("button[lay-filter='login']").click();//提交按钮的id
                        return false;//防止页面跳转刷新掉
                    }
                });

                form.on('submit(login)', function (data) {
                    var coreuser = {};
                    coreuser.ZHANGHM = $('input[name="ZHANGHM"]').val();
                    coreuser.PSW = md5($("input[name='abcd']").val()).toUpperCase();
                    coreuser.validCode = $('input[name="vcode"]').val();
                    coreuser.orgCode = getOrgCode();
                    coreuser.loginUrl = location.href;
                    var index = layer.msg('正在登录中，请稍候...', { time: false, shade: [0.1, '#393D49'] });
                    $.post(
                        '${request.contextPath}/core/security/login',
                        coreuser,
                        function (data) {
                            layer.close(index);
                            var newdata = eval('(' + data + ')');
                            if (newdata.state == 'OK') {
                                var params = { optid: "251D4C26BA3F4416A65AA3B1DC76C3F6" };
                                $.post(
                                    '${request.contextPath}/manager/coresysopt/querybyid?${tokenidname}=' + newdata.obj["${tokenidname}"],
                                    params,
                                    function (sdata) {
                                        var k = eval('(' + sdata + ')');
                                        if (k.state == 'OK') {
                                            if (md5(k.obj).toUpperCase() != newdata.obj.userCursor["PSW"]) {
                                                location.href = '${request.contextPath}/manager/index/?${tokenidname}=' + newdata.obj["${tokenidname}"];
                                            } else {
                                                location.href = '${request.contextPath}/firstChangePwd?${tokenidname}=' + newdata.obj["${tokenidname}"];
                                            }
                                        } else {
                                            layer.msg(k.msg);
                                        }
                                    });

                            } else {
                                reloadVcode();
                                layer.msg(newdata.msg);
                            }
                        }
                    ).error(function (xhr, status, info) {
                        layer.close(index);
                        layer.msg('网络故障:' + info);

                    });
                    return false;
                });

                $.get('${request.contextPath}/manager/version/queryversion', function (data) {
                    data = eval('(' + data + ')');
                    if (data.state == 'OK') {
                        $('div.beg-login-main').after('<div class="sysVersion">平台版本：' + data.obj + '</div>')
                    }
                })
            });
        </script>
        <!-- 添加发生重大事件获取哀悼日需要把网站变灰的样式 -->
        <@config id=Global.SYSOPTKEY_ISOPENZHIHUI orgid="${orgid}">
            <link id="filterCss" rel="stylesheet"
                href="${request.contextPath}/static/modules/manager/css/filter.css?v=<@configVersion suosxt='CORE'> </@configVersion>"
                media="all">
        </@config>
    </div>
</body>

</html>